Option Explicit

Public Sub main()
    Dim wb As Workbook
    Set wb = ActiveWorkbook

    Dim form As VBComponent

    ' ==================================================
    ' 1. 设置 form 的属性
    ' ==================================================
    Set form = wb.VBProject.VBComponents.Item("MyProgressBar")
    With form
        .Properties("Height") = 232.4
        .Properties("Width") = 369.6
        .Properties("Caption") = "progress"
    End With

    ' ==================================================
    ' 2. 设置 form 中各个组件的属性，需要注意顺序，防止组件间的覆盖
    ' ==================================================
    Dim ctrs As Controls
    Dim component as Control
    Set ctrs = form.Designer.Controls

    ' 1. 生成进度条的底色部分
    Set component = UtilsControl.createLabel(ctrs, "lblBack", _
        24, 306, 18, 18, caption:="", fontSize:=18)
    ' 设置背景色
    component.Object.BackColor = &HFFFF80

    ' 2. 生成进度条的推进部分
    Set component = UtilsControl.createLabel(ctrs, "lblprogress", _
        24, 36, 18, 18, caption:="", fontSize:=18)
    ' 设置背景色
    component.Object.BackColor = &HFF0000

    ' 3. 生成进度条的百分比数值部分
    Set component = UtilsControl.createLabel(ctrs, "percent", _
        24, 90, 138, 18, caption:="Label3", fontSize:=18)
    ' 设置背景色
    With component.Object
        .BackColor = &HFF0000
        .BackStyle = 0
        .BorderColor = &HFF&
        .ForeColor = &HFF&
        .TextAlign = 2
        .Font.Bold = True
    End With

    ' 4. 生成进度条消息部分
    Set component = UtilsControl.createLabel(ctrs, "msg", _
        126, 282, 36, 54, caption:="", fontSize:=10)

End Sub
